package com.happe.foodeasy.winter.conf.parser;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * This class is used to retrieve databaseTypeMapResult.
 * Created by wubin on 2016-05-19.
 */
@Component
public class DatabaseTypeParseTemplate {
    @Autowired
    private WinterConfInformationParser confInformationParser;
    @Autowired
    private DatabaseTypeParser parser;

    /**
     * This class uses WinterConfInformationParser Object to return the name of target database, and
     * parse the database type's configuration file with DatabaseTypeParser Object.
     *
     * @return the result of parsing database type's configuration file.
     */
    public DatabaseTypeMapParseResult retrieveMapResult() {
        ConfInformationParseResult result = confInformationParser.startParse();
        parser.setDatabaseType(result.getDatabaseName());
        return parser.startParse();
    }

    public void setParser(DatabaseTypeParser parser) {
        this.parser = parser;
    }
}
